<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8">
    <title>设置阶段</title>
</head>
<body>
<div style="max-width: 450px;max-height: 450px;">
    <form id="form" role="form" method="post" th:action="${action}">
        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="stage">阶段</label>
                    <select class="form-control" id="stage" name="stage">
                        <option th:selected="${entity.getStage()=='' or entity.getStage() ==null?true:false}"
                                value=-1>无
                        </option>
                        <!--<option th:selected="${entity.getStage()=='P-x-P0阶段'?true:false}" value="P-x-P0阶段">P-x-P0阶段</option>-->
                        <option th:selected="${entity.getStage()==1?true:false}" value=1>P0-P1阶段
                        </option>
                        <option th:selected="${entity.getStage()==2?true:false}" value=2>P1-P2阶段
                        </option>
                        <option th:selected="${entity.getStage()==3?true:false}" value=3>P2-P3阶段
                        </option>
                        <option th:selected="${entity.getStage()==4?true:false}" value=4>P3-P4阶段
                        </option>
                        <option th:selected="${entity.getStage()==5?true:false}" value=5>P4-P5阶段
                        </option>
                        <option th:selected="${entity.getStage()==6?true:false}" value=6>P5-P6阶段
                        </option>
                        <option th:selected="${entity.getStage()==7?true:false}" value=7>P6-P7阶段
                        </option>
                        <option th:selected="${entity.getStage()==8?true:false}" value=8>P7-P8阶段
                        </option>
                        <option th:selected="${entity.getStage()==0?true:false}" value=9>P8-P9阶段
                        </option>
                        <option th:selected="${entity.getStage()==10?true:false}" value=10>P9-P10阶段
                        </option>
                    </select>
                    <div class="form-group">
                        <label>更新版本</label>
                        <table>
                            <tr>
                                <td><input class="form-control col-md-7"
                                           th:value="${entity.getVersion().substring(0,entity.getVersion().indexOf('.'))}"
                                           id="version1" name="version1"
                                           disabled="disabled"
                                />
                                </td>
                                <td style="font-size: 32px">.</td>
                                <td><input class="form-control col-md-6"
                                           th:value="${entity.getVersion().substring(entity.getVersion().indexOf('.')+1)}"
                                           id="version2" name="version2"
                                           disabled="disabled"
                                /></td>
                            </tr>
                        </table>
                    </div>
                    <div class="form-group">
                        <label>生效日期</label>
                        <input class="form-control" th:value="${releaseDate}"
                               disabled="disabled"
                        />
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script th:inline="javascript">
    <![CDATA[
    $(function () {
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            var url = $("#form", window.top.document).attr('action');
            var projectPuid = $("#project", window.top.document).val();
            <!--其实不要puid，puid会在服务器上生成-->
            var data = {};
            data.projectPuid = projectPuid;
            var _d = $("#form").serializeArray();
            for (var p in _d) {
                if (_d.hasOwnProperty(p)) {
                    data[_d[p].name] = _d[p].value;
                }
            }
            $.ajax({
                contentType:
                    "application/json",
                type:
                    'POST',
                url: url,
                data: JSON.stringify(data),
                success:
                    function (result) {
                        // $('.modal-dialog', window.top.document).parent('div').remove();
                        // $('body', window.top.document).find('.modal-backdrop').remove();
                        activeTabBodyReset();
                        if (result.status) {
                            $(window.parent.document).contents().find(".tab-pane.fade.active.in iframe")[0].contentWindow.doRefresh(getProjectUid());
                            layer.msg(result.msg, {icon: 1, time: 2000});
                        } else {
                            window.Ewin.alert({message: result.msg});
                        }
                    },
                error: function (status) {
                    window.Ewin.alert({message: status.status + ':设置阶段数据失败!'});
                }
            });
        });
    })
    ]]>
</script>
</body>
</html>